﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NeuralNetwork_Visual
{
    public partial class MainWindow : Form
    {
        public double FunctionParameter { get ; set; }
        public double HiddenLayersCount { get { return LayersRepresentation.Count - 2;  } }
        public List<LayerRepresentation> LayersRepresentation { get; set; }

        public void InitializeNetworkConstructor()
        {
            LayersRepresentation = new List<LayerRepresentation>();
            LayersRepresentation.Add(new LayerRepresentation("Inputs", 0, 2, false));
            LayersRepresentation.Add(new LayerRepresentation("Output Layer", 0, 1, false));
            networkGridView.DataSource = LayersRepresentation;
            networkGridView.Refresh();
        }
        public void AddHiddenLayer(String Name = "Layer")
        {
            LayerRepresentation outputs = LayersRepresentation.Last<LayerRepresentation>();
            LayersRepresentation.Remove(outputs);
            LayersRepresentation.Add(new LayerRepresentation("Hidden Layer", 0, 1, false));
            LayersRepresentation.Add(outputs);
            networkGridView.DataSource = LayersRepresentation;
            networkGridView.Refresh();
        }
        public void RemoveHiddenLayer()
        {
            LayerRepresentation outputs = LayersRepresentation.Last<LayerRepresentation>();
            LayersRepresentation.Remove(outputs);
            LayersRepresentation.Remove(LayersRepresentation.Last<LayerRepresentation>());
            LayersRepresentation.Add(outputs);
            networkGridView.DataSource = LayersRepresentation;
            networkGridView.Refresh();
        }
        public MainWindow()
        {
            InitializeComponent();
        }

        private void MainWindow_Load(object sender, EventArgs e)
        {
            this.activationFunctionDropDown.SelectedIndex = 0;
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InitializeNetworkConstructor();
        }

        private void addHiddenLayerButton_Click(object sender, EventArgs e)
        {
            AddHiddenLayer();
        }

        private void removeHiddenLayerButton_Click(object sender, EventArgs e)
        {
            RemoveHiddenLayer();
        }


    }
}
